package com.um.jdy.common.member.service.impl;


import org.springframework.stereotype.Service;
import lombok.extern.slf4j.Slf4j;
import com.um.springboot.starter.orm.service.BaseEntityServiceImpl;
import com.um.jdy.common.member.service.WalletService;
import com.um.jdy.common.member.dao.WalletDao;
import com.um.jdy.common.member.entity.po.Wallet;

/**
 * 服务实现类：用户钱包流水表
 */
@Service
@Slf4j
public class WalletServiceImpl extends BaseEntityServiceImpl<WalletDao,Wallet>  implements WalletService{

    /**
     * 获取用户余额
     *
     * @param uid
     * @return
     */
    @Override
    public int getBalance(String uid,String comId) {
        return dao.queryObjectBySqlName("get_wallet_balance", new Object[]{uid,comId}, Integer.class);
    }

    /**
     * 获取用户可提现余额
     *
     * @param uid
     * @return
     */
    @Override
    public int getCanCashoutBalance(String uid,String comId) {
        int balance = dao.queryObjectBySqlName("get_can_cashout_wallet_balance", new Object[]{uid,comId}, Integer.class);
        return Math.max(0,balance);
    }
}
